package com.huli.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huli.domain.OwnerIncome;
import com.huli.dto.OwnerIncomeDto;
import com.huli.param.OwnerIncomeParam;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OwnerIncomeMapper extends BaseMapper<OwnerIncome> {

    //通过位主id查询位主 日收入
    @Select("SELECT * from owner_income  WHERE owner_id =#{ownerId}")
    public List<OwnerIncome> selectOwnerDayIncomeById(int ownerId);


    //通过位主id查询位主 月收入
    @Select("SELECT owner_id,YEAR(owner_income_time) year,MONTH(owner_income_time) month ," + "SUM(owner_income_money) monthIncome FROM owner_income" +
            " WHERE MONTH(owner_income_time) = #{month} GROUP BY owner_id,YEAR(owner_income_time),MONTH(owner_income_time) HAVING owner_id = #{ownerId}")
    public OwnerIncomeDto selectOwnerMonthIncomeById(OwnerIncomeParam ownerIncomeParam);

}
